Skip to content

samples: sync NotesApp with latest ACI API changes#606

Draft
surajkumar-08 wants to merge 7 commits intomicrosoft:release/experimentalfrom
surajkumar-08:sync-notesapp-aci-updates
Draft

samples: sync NotesApp with latest ACI API changes#606
surajkumar-08 wants to merge 7 commits intomicrosoft:release/experimentalfrom
surajkumar-08:sync-notesapp-aci-updates

Conversation

@surajkumar-08
Copy link
Copy Markdown

@surajkumar-08 surajkumar-08 commented Mar 16, 2026

Summary

Update NotesApp sample to WinAppSDK 2.0.0-preview1 ACI API surface

Namespace & API renames

  • Update namespace from Microsoft.Windows.AI.Search.Experimental.AppContentIndex to Microsoft.Windows.Search.AppContentIndex
  • Rename RemoveRemoveContentItem, RemoveAllRemoveAllContentItems
  • Use RegionOfInterest (on AppManagedImageQueryMatch) instead of Subregion (which remains on AppManagedOcrTextQueryMatch for OCR matches)

New API usage

  • Add pre-flight system capability checks via GetIndexCapabilitiesOfCurrentSystem() before creating an index
  • Subscribe to AppContentIndexListener events (IndexCapabilitiesChanged, IndexStatisticsChanged, ContentItemStatusChanged) for live index monitoring
  • Drive search UI progress bar from IndexStatisticsChanged events
  • Log index statistics via GetIndexStatistics() on startup

Resource management & robustness

  • Dispose AppContentIndexer in MainWindow.Closed handler
  • Add IDisposable to SearchViewModel; call Dispose() via SearchView.Unloaded to release CancellationTokenSource
  • Replace int.Parse with int.TryParse for image match ContentId to avoid FormatException
  • Replace throw new Exception with throw new InvalidOperationException

Cleanup

  • Update WinAppSDK from 2.0.0-experimental3 to 2.0.0-preview1
  • Remove stale commented-out internal project references from csproj
  • Fix README: correct solution filename, update SDK version reference
  • Clean up Package.appxmanifest identity for public sample

Checklist

Note that /azp run currently isn't working for this repo.

surakumar_microsoft and others added 6 commits March 12, 2026 16:24
- Update namespace from Microsoft.Windows.AI.Search.Experimental.AppContentIndex
  to Microsoft.Windows.Search.AppContentIndex
- Rename Remove -> RemoveContentItem, RemoveAll -> RemoveAllContentItems
- Rename Subregion -> RegionOfInterest on image query matches
- Update WinAppSDK from 2.0.0-experimental3 to 2.0.0-preview1
- Add IDisposable to SearchViewModel for proper cleanup
- Remove stale commented-out internal project references from csproj
- Fix README: correct solution filename, update SDK version reference
- Clean up Package.appxmanifest identity for public sample

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Rename SearchViewModel._currentSearchCancellation (was missing '_' prefix,
  inconsistent with _searchText convention)
- Call SearchViewModel.Dispose() via SearchView.Unloaded to release
  CancellationTokenSource when the control is torn down
- Dispose AppContentIndexer in MainWindow.Closed handler so IClosable
  resources are released on window close
- Replace int.Parse with int.TryParse for image match ContentId to avoid
  FormatException on unexpected content IDs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@surajkumar-08
Copy link
Copy Markdown
Author

@abhmondal_microsoft can you please provide your review.

@surajkumar-08
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

return null;
}

string fragment = match.GetType().GetProperty("Fragment")?.GetValue(match) as string ?? string.Empty;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetType().GetProperty("Fragment") pattern for reading OCR results is the only reflection-based property access in the entire samples repo. If the API renames that property in a future preview, this silently returns null and displays empty text with no error.

Is this a temporary workaround for a property not yet projected in the preview SDK? If so, could we add a // TODO: Replace with direct property access when projected comment so developers copying this sample know it's not the recommended pattern?


private void TextQuerySession_ResultChanged(AppIndexTextQuerySession sender, object args)
{
_ = RefreshQuerySessionResultsAsync();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ = RefreshQuerySessionResultsAsync() discards the Task, so if the query session throws (e.g., after disposal or on an unsupported system), the exception vanishes and search silently stops working. Since this sample teaches developers how to use the Content Search API, would it be worth wrapping this in a try/catch with a logged or displayed error? Even a Debug.WriteLine would make failures visible when developers are adapting this code.

<!-- Azure Settings Card -->
<toolkit:SettingsCard x:Name="AzureSettingsCard" Header="AzureSettings" Visibility="Collapsed" HorizontalContentAlignment="Left" ContentAlignment="Left">
<StackPanel Margin="-42,-24,0,12" Spacing="8">
<Border x:Name="AzureSettingsCard"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The switch from SettingsCard to Border removes the keyboard navigation and Narrator landmarks that SettingsCard provides out of the box. Since developers often copy sample XAML patterns directly, could we preserve accessibility here — either by keeping SettingsCard or adding AutomationProperties to the replacement controls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants